﻿#nullable enable

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace PHMEE.EnergyEfficiency;

public interface IFuelAppService
{
    // /// <summary>
    // /// 当前主机、副机、锅炉所用燃料类型
    // /// </summary>
    // /// <param name="vesselId"></param>
    // /// <returns></returns>
    // [Obsolete]
    // Task<CurrentFuelTypeDto> CurrentFuelTypeAsync(Guid vesselId);

    #region 普通油耗量查询

    // /// <summary>
    // /// 小时油耗量
    // /// </summary>
    // /// <param name="vesselId"></param>
    // /// <param name="hour"></param>
    // /// <returns></returns>
    // [Obsolete]
    // Task<IReadOnlyList<FuelMeasurement>> FuelConsumptionForHour(Guid vesselId,
    //     DateTime? hour);

    /// <summary>
    /// 日油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="date"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> FuelConsumptionForDay(Guid vesselId,
        DateTime? date);

    /// <summary>
    /// 油耗量查询（具体到分钟）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="startDateTime"></param>
    /// <param name="endDateTime"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> FuelConsumptionForDateTimePeriod(Guid vesselId,
        DateTime startDateTime, DateTime endDateTime);

    /// <summary>
    /// 航次油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="voyageStartTime"></param>
    /// <param name="voyageEndTime"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> FuelConsumptionForVoyage(Guid vesselId, DateTime voyageStartTime,
        DateTime voyageEndTime);

    /// <summary>
    /// 年油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="year"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> FuelConsumptionForYear(Guid vesselId,
        int? year);
        
    #endregion 普通油耗量查询

    #region 应急油耗量查询

    /// <summary>
    /// 应急油耗-日油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="date"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> EmrgFuelConsumptionForDay(Guid vesselId,
        DateTime? date);

    /// <summary>
    /// 应急油耗-油耗量查询（具体到分钟）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="startDateTime"></param>
    /// <param name="endDateTime"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> EmrgFuelConsumptionForDateTimePeriod(Guid vesselId,
        DateTime startDateTime, DateTime endDateTime);

    /// <summary>
    /// 应急油耗-航次油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="voyageStartTime"></param>
    /// <param name="voyageEndTime"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> EmrgFuelConsumptionForVoyage(Guid vesselId, DateTime voyageStartTime,
        DateTime voyageEndTime);

    /// <summary>
    /// 应急油耗-年油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="year"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> EmrgFuelConsumptionForYear(Guid vesselId,
        int? year);

    #endregion 应急油耗量查询

    #region 混合油耗查询

    /// <summary>
    /// 混合油耗-日油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="date"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> MixFuelConsumptionForDay(Guid vesselId,
        DateTime? date);

    /// <summary>
    /// 混合油耗-油耗量查询（具体到分钟）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="startDateTime"></param>
    /// <param name="endDateTime"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> MixFuelConsumptionForDateTimePeriod(Guid vesselId,
        DateTime startDateTime, DateTime endDateTime);

    /// <summary>
    /// 混合油耗-航次油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="voyageStartTime"></param>
    /// <param name="voyageEndTime"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> MixFuelConsumptionForVoyage(Guid vesselId, DateTime voyageStartTime,
        DateTime voyageEndTime);

    /// <summary>
    /// 混合油耗-年油耗量
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="year"></param>
    /// <returns></returns>
    Task<FuelConsumptionDto> MixFuelConsumptionForYear(Guid vesselId,
        int? year);

    #endregion 混合油耗查询

    /// <summary>
    /// 油品即时存量显示
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="time"></param>
    /// <returns></returns>
    Task<IReadOnlyList<FuelMeasurement>> FuelInventoryAsync(Guid vesselId, DateTime? time);

    /// <summary>
    /// 录入油品存量显示（数据来自 LogAbstract 的 ROB）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="time"></param>
    /// <returns></returns>
    Task<IReadOnlyList<FuelMeasurement>> FuelInventoryFromLogAbstractAsync(Guid vesselId, DateTime? time);

    /// <summary>
    /// 时间段平均油耗量查询对比（单位为小时）具体到分钟
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="ts1StartDateTime"></param>
    /// <param name="ts1EndDateTime"></param>
    /// <param name="ts2StartDateTime"></param>
    /// <param name="ts2EndDateTime"></param>
    /// <returns></returns>
    Task<IReadOnlyList<FuelConsumptionComparisonDto>> AverageFuelConsumptionComparison(Guid vesselId,
        DateTime ts1StartDateTime, DateTime ts1EndDateTime,
        DateTime ts2StartDateTime, DateTime ts2EndDateTime);

    /// <summary>
    /// 航次平均油耗量对比（单位为小时）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="voyage1StartTime"></param>
    /// <param name="voyage1EndTime"></param>
    /// <param name="voyage2StartTime"></param>
    /// <param name="voyage2EndTime"></param>
    /// <returns></returns>
    Task<IReadOnlyList<FuelConsumptionComparisonDto>> VoyageAverageFuelConsumptionComparison(Guid vesselId,
        DateTime voyage1StartTime, DateTime voyage1EndTime, DateTime voyage2StartTime, DateTime voyage2EndTime);
    
    /// <summary>
    /// 年度平均油耗量对比（单位为小时）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="year1"></param>
    /// <param name="year2"></param>
    /// <returns></returns>
    Task<IReadOnlyList<FuelConsumptionComparisonDto>> YearAverageFuelConsumptionComparison(Guid vesselId,
        int year1, int year2);

    // /// <summary>
    // /// 发电柴油机即时油耗和油品
    // /// </summary>
    // /// <param name="vesselId"></param>
    // /// <returns></returns>
    // Task<FuelConsumptionWithTypeDto> DieselGeneratorsInstantFuelConsumptionAsync(Guid vesselId);

    /// <summary>
    /// time 前的单次加油量查询
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="time"></param>
    /// <returns></returns>
    Task<IEnumerable<FuelMeasurement>> RefuelSingleTimeAsync(Guid vesselId, DateTime? time);

    /// <summary>
    /// 加油量查询（日期段）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="startDate"></param>
    /// <param name="endDate"></param>
    /// <returns></returns>
    Task<IEnumerable<FuelMeasurement>> RefuelSummaryInDateRangeAsync(Guid vesselId, DateTime startDate,
        DateTime endDate);

    /// <summary>
    /// 加油量查询（年）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="year"></param>
    /// <returns></returns>
    Task<IEnumerable<FuelMeasurement>> RefuelSummaryInYearAsync(Guid vesselId, int? year);

    // /// <summary>
    // /// 每个燃油流量计采集到的最新的值
    // /// </summary>
    // /// <param name="vesselId"></param>
    // /// <returns></returns>
    // Task<FuelFlowMeterValues> FuelFlowMeterValuesAsync(Guid vesselId);

    /// <summary>
    /// 油耗分析
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="period"></param>
    /// <param name="fuelType"></param>
    /// <returns></returns>
    Task<List<FuelConsumptionAnalyzeDto>> FuelConsumptionAnalyzeAsync(Guid vesselId, FuelConsumptionAnalyzePeriod period,
        FuelType fuelType);

    /// <summary>
    /// 检查 LA Fuel 密码是否正确
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="laFuelPassword"></param>
    /// <returns></returns>
    Task<bool> CheckLAFuelPasswordAsync(Guid vesselId, string laFuelPassword);

    /// <summary>
    /// 修改 LA Fuel 密码
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="newLaFuelPassword"></param>
    /// <returns></returns>
    Task<bool> ChangeLAFuelPasswordAsync(Guid vesselId, string newLaFuelPassword);
}